<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>后台管理系统</title>
	    <meta name="author" content="BaiYY"/>
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	    <meta name="renderer" content="webkit">
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
	    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-paginator.js"></script>
	    <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
	</head>
	<body>
		<div class="right-sidebar" style="max-width: 1200px;">
			<section class="table-responsive">
				<table class="table table-bordered">
					<thead>
						<tr>
							<th>日期</th>
							<th>新注册用户数</th>
							<th>次日留存数</th>
							<th>三日留存数</th>
							<th>七日留存数</th>
						</tr>
					</thead>
					<tbody id="dataList"></tbody>
				</table>
			</section>
			<div style="margin: 10px auto;" ><a href="{:U('Admin/Main/relTimeExport')}" class="btn btn-primary">全部导出excel</a></div>
			<ul class="page" id="page" style="width: 100%;overflow: hidden;"></ul>
		</div>
		<script type="text/javascript">
			$(function(){
				$.ajax({
					type:"post",
					timeout:5000,  //超时设置   单位毫秒
					url:"{:U('Admin/Main/realTimePage')}",
					success:function(datas) {
//						console.log(datas);
						datas.reverse();
						if(datas != 'nodata' && datas) {
							options={
								"id":"page",//显示页码的元素
								"data":datas,//显示数据
							    "maxshowpageitem":2,//最多显示的页码个数
							    "pagelistcount":10,//每页显示数据个数
							    "callBack":function(data) {
//							    	console.log(data);
							    	var str = '';
							    	var times = '';
							    	for(var i=0;i<data.length;i++) {
                                        data[i].day = data[i].day + '';
							    	    times = data[i].day.substr(0,4)+'-'+data[i].day.substr(4,2)+'-'+data[i].day.substr(6,2);
							    		str +="<tr><td>"+times+"</td><td>"+data[i].count+"</td><td>"+data[i].num1+"</td><td>"+data[i].num3+"</td><td>"+data[i].num7+"</td></tr>";
							    	}
							    	$("#dataList").html(str);
							    }
							}
							page.init(datas.length,1,options);
						}else if(datas == 'nodata') {
							alert("网络延时，请重刷页面！");
						}
					},
					complete:function(XMLHttpRequest,status){
						if(status == 'timeout') {
							ajaxTimeoutTest.abort();
							alert("请求超时");
						}
					}
				});
			});
		</script>
	</body>
</html>
